import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
const path = require("path");
import styleImport from "vite-plugin-style-import";
const resolve = (dir: string): string => path.resolve(__dirname, dir);
// https://vitejs.dev/config/
export default defineConfig({
  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true,
        additionalData: `@import "${path.resolve(
          __dirname,
          "./src/styles/variable.less"
        )}";`,
      },
    },
  },
  plugins: [
    styleImport({
      libs: [
        {
          libraryName: "ant-design-vue",
          esModule: true,
          ensureStyleFile:true,
          resolveStyle: (name) => {
            return `ant-design-vue/es/${name}/style/css`;
          },
        },
      ],
    }),
    vue(),
  ],
  resolve: {
    extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json"],
    alias: [{ find: "@", replacement: resolve("src") }],
  },
});
